<?php defined('In33hao') or exit('Access Invalid!');?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>商家管理中心登录</title>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.validation.min.js"></script>
<link href="<?php echo SHOP_TEMPLATES_URL?>/css/base.css" rel="stylesheet" type="text/css">
<link href="<?php echo SHOP_TEMPLATES_URL?>/css/seller_center.css" rel="stylesheet" type="text/css">
<link href="<?php echo SHOP_RESOURCE_SITE_URL;?>/font/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<!--[if IE 7]>
  <link rel="stylesheet" href="<?php echo SHOP_RESOURCE_SITE_URL;?>/font/font-awesome/css/font-awesome-ie7.min.css">
<![endif]-->
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.validation.min.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="<?php echo RESOURCE_SITE_URL;?>/js/html5shiv.js"></script>
      <script src="<?php echo RESOURCE_SITE_URL;?>/js/respond.min.js"></script>
<![endif]-->
<script language="JavaScript" type="text/javascript">
window.onload = function() {
    tips = new Array(2);
    tips[0] = document.getElementById("loginBG01");
    tips[1] = document.getElementById("loginBG02");
    index = Math.floor(Math.random() * tips.length);
    tips[index].style.display = "block";
};
$(document).ready(function() {
    //更换验证码
    function change_seccode() {
        $('#codeimage').attr('src', 'index.php?act=seccode&op=makecode&nchash=<?php echo $output['nchash'];?>&t=' + Math.random());
        $('#captcha').select();
    }

    $('[nctype="btn_change_seccode"]').on('click', function() {
        change_seccode();
    });

    //登陆表单验证
    $("#form_login").validate({
        errorPlacement:function(error, element) {
            element.prev(".repuired").append(error);
        },
        onkeyup: false,
        rules:{
            seller_name:{
                required:true
            },
            auth_code:{
                required:true
            },
            captcha:{
                required:true,
                remote:{
                    url:"index.php?act=seccode&op=check&nchash=<?php echo $output['nchash'];?>",
                    type:"get",
                    data:{
                        captcha:function() {
                            return $("#captcha").val();
                        }
                    },
                    complete: function(data) {
                        if(data.responseText == 'false') {
                            change_seccode();
                        }
                    }
                }
            }
        },
        messages:{
            seller_name:{
                required:"<i class='icon-exclamation-sign'></i>手机号不能为空"
            },
            captcha:{
                required:"<i class='icon-exclamation-sign'></i>验证码不能为空"
            },
            auth_code:{
                required:"<i class='icon-exclamation-sign'></i>动态验证码不能为空",
                remote:"<i class='icon-frown'></i>动态验证码错误"
            }
        }
    });


    /**
     * 发送验证码
     */
    $(".sendBtn").click(function(){

        var phone = $("#mobile").val();
        var captcha = $("#captcha").val();

        if (phone==''){
            $('.repuired').eq(0).html("<i class='icon-exclamation-sign'></i>手机号不能为空");
            return;
        }else{
            var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if (!myreg.test(phone)){
                $('.repuired').eq(0).html("<i class='icon-exclamation-sign'></i>请填写正确的手机号");
                return;
            }else{
                $('.repuired').eq(0).html("");
            }
        }

        if (captcha==''){
            $('.repuired').eq(1).html("<i class='icon-exclamation-sign'></i>验证码不能为空");
            return;
        }else{
            $('.repuired').eq(1).html("");
        }
        var isSend = true;
        // 验证图片验证码
        $.ajax({
            url:"index.php?act=seccode&op=check&nchash=<?php echo $output['nchash'];?>",
            type:"get",
            data: {
                captcha: captcha,
            },
            success:function(data){
                   if(data=='false'){
                         isSend = false;
                   }
                   if (!isSend){
                         return false;
                   }
                   // 发送验证码
                   $.ajax({
                        url:"index.php?act=seller_login&op=sendMobile&nchash=<?php echo $output['nchash'];?>",
                        type:"get",
                        data: {
                            mobile : phone,
                        },
                        dataType:"json",
                        success:function(data){
                            if(data.status==200){
                                $("#_mobile").val(phone);
                                $("#_mid").val(data.member_id);
                                $("#error_tips").hide();
                                $(".sendBtn").hide();
                                document.getElementsByClassName('send_msm')[0].style.display = 'block';
                                cutdown();
                            }else{
                                 $("#error_tips").show();
                                 $("#error_tips").html(data.msg);
                            }
                        }
                   })
            }
        })
    })

    time = getCookie('times');
    if(time>0){
        $(".sendBtn").hide();
        $('#time').html(time);
        document.getElementsByClassName('send_msm')[0].style.display = 'block';
        cutdown();
    }

    /**
     * 倒计时
     */
    function cutdown(){
         var time = $("#time").html();
         var timer = setInterval(function(){
              if(time<=0){
                   delCookie('times');
                   $('#time').html(10);
                   $(".sendBtn").show();
                   document.getElementsByClassName('send_msm')[0].style.display = 'none';
                   clearInterval(timer);
                   return;
              }
              time--;
              addCookie('times',time);
              $('#time').html(time);
         },1000)
    }

    function addCookie(name,value,expireHours){
        var cookieString=name+"="+escape(value)+"; path=/";
        //判断是否设置过期时间
        if(expireHours>0){
            var date=new Date();
            date.setTime(date.getTime()+expireHours*3600*1000);
            cookieString=cookieString+";expires="+date.toGMTString();
        }
        document.cookie=cookieString;
    }

    function delCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() + (-1 * 24 * 60 * 60 * 1000));
        var cval = getCookie(name);
        document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }

    function getCookie(name){
        var strcookie=document.cookie;
        var arrcookie=strcookie.split("; ");
        for(var i=0;i<arrcookie.length;i++){
            var arr=arrcookie[i].split("=");
            if(arr[0]==name)return unescape(arr[1]);
        }
        return null;
    }

    //Hide Show verification code
    $("#hide").click(function(){
        $(".code").fadeOut("slow");
    });
    $("#captcha").focus(function(){
        $(".code").fadeIn("fast");
    });

});
</script>
</head>
<body>
<div id="loginBG01" class="ncsc-login-bg">
  <p class="pngFix"></p>
</div>
<div id="loginBG02" class="ncsc-login-bg">
  <p class="pngFix"></p>
</div>
<div class="ncsc-login-container">
  <div class="ncsc-login-title">
    <h2 style="width: 100%; text-align: center;">商家管理中心</h2>
<!--    <h4><a href="--><?php //echo urlChain('login');?><!--">门店管理登录</a></h4>-->
    <span>请使用会员中心绑定的手机号登陆</span></div>
  <form id="form_login" action="index.php?act=seller_login&op=mobilelogin" method="post" onsubmit="delCookie('times')">
    <?php Security::getToken();?>
    <input name="nchash" type="hidden" value="<?php echo $output['nchash'];?>" />
    <input type="hidden" name="form_submit" value="ok" />
    <div class="input">
      <label>手机号</label>
      <span class="repuired"></span>
      <input name="seller_name" type="text" id="mobile" autocomplete="off" class="text" autofocus>
      <input name="mobile" type="hidden" id="_mobile" autocomplete="off" class="text">
      <input name="mid" type="hidden" id="_mid" autocomplete="off" class="text">
      <span class="ico"><i class="icon-mobile-phone"></i></span> </div>
      <div class="input">
          <label>验证码</label>
          <span class="repuired"></span>
          <input type="text" name="captcha" id="captcha" autocomplete="off" class="text" style="width: 80px;" maxlength="4" size="10" />
          <div class="code">
              <div class="arrow"></div>
              <div class="code-img"><a href="javascript:void(0)" nctype="btn_change_seccode"><img src="index.php?act=seccode&op=makecode&nchash=<?php echo $output['nchash'];?>" name="codeimage" border="0" id="codeimage"></a></div>
              <a href="JavaScript:void(0);" id="hide" class="close" title="<?php echo $lang['login_index_close_checkcode'];?>"><i></i></a> <a href="JavaScript:void(0);" class="change" nctype="btn_change_seccode" title="<?php echo $lang['login_index_change_checkcode'];?>"><i></i></a> </div>
         <div class="sendMsm">
              <a href="javascript:void(0)" class="sendBtn">发送验证码</a>
              <div class="send_msm">验证码已发送至手机 <span id="time">60</span>s 重新发送</div>
         </div>
      </div>
    <div class="input">
      <label>动态验证码</label>
      <span class="repuired"></span>
      <input name="auth_code" type="password" autocomplete="off" style="width: 80px" class="text">
      <span class="ico"><i class="icon-key"></i></span>
        <span class="ico"><i class="icon-qrcode"></i></span>
        <input type="submit" class="login-submit" value="确认登录">
    </div>
    <p id="error_tips" style="display: none; color: #ff6666;">该手机未注册或未绑定商城账号</p>
    <div class="mt10 fr"><a href="<?php echo SHOP_SITE_URL;?>" title="返回首页">返回首页</a></div>
  </form>
  <!--<div class="copyright">Powered by <?php echo $output['setting_config']['33hao_version'];?> © 2005-2016 <a href="http://www.33hao.com/" target="_blank">33hao.com</a> </div>-->
</div>
</body>
</html>
